package lumis.content.control.dynamiclist;

import lumis.doui.control.dynamiclist.DynamicListControl;
import lumis.portal.PortalException;
import lumis.portal.authentication.SessionConfig;
import lumis.portal.manager.ManagerFactory;
import lumis.portal.serviceinstance.ServiceInstanceConfig;
import lumis.service.categorization.CategorizationServiceInstanceProvider;

/**
 * Dynamic list control that customizes the service instance of the popup interface for selecting terms.
 * This control detects the service instance of the popup interface based on the categorization
 * service instance associated to the current interface service instance.
 *
 * @version $Revision: 9601 $ $Date: 2008-07-18 15:38:17 -0300 (Fri, 18 Jul 2008) $
 * @since 4.2.0
 */
public class TermDynamicListControl extends DynamicListControl
{
	protected String getPopupAddInterfaceServiceInstanceId() throws PortalException
	{
		ServiceInstanceConfig serviceInstanceConfig = ManagerFactory.getServiceInstanceManager().getServiceInstanceByDependency(SessionConfig.getCurrentSessionConfig(), this.douiContext.getRequest().getServiceInstanceConfig().getId(), CategorizationServiceInstanceProvider.REPOSITORY_ID, this.douiContext.getTransaction());
		if(serviceInstanceConfig == null)
			throw new PortalException("No categorization service associated to current service instance: "+this.douiContext.getRequest().getServiceInstanceConfig().getId());
		
		return serviceInstanceConfig.getId();
	}
}
